/*   1:    */ package com.atomikos.datasource.xa.session;
/*   2:    */ 
/*   3:    */ import com.atomikos.datasource.xa.XATransactionalResource;
/*   4:    */ import com.atomikos.icatch.CompositeTransaction;
/*   5:    */ import com.atomikos.icatch.HeuristicMessage;
/*   6:    */ import com.atomikos.icatch.system.Configuration;
/*   7:    */ import javax.transaction.xa.XAResource;
/*   8:    */ 
/*   9:    */ class TransactionContext
/*  10:    */ {
/*  11:    */   private TransactionContextStateHandler state;
/*  12:    */   
/*  13:    */   TransactionContext(XATransactionalResource resource, XAResource xaResource)
/*  14:    */   {
/*  15: 51 */     setState(new NotInBranchStateHandler(resource, xaResource));
/*  16:    */   }
/*  17:    */   
/*  18:    */   private synchronized void setState(TransactionContextStateHandler state)
/*  19:    */   {
/*  20: 57 */     if (Configuration.isDebugLoggingEnabled()) {
/*  21: 57 */       Configuration.logDebug(this + ": changing to state " + state);
/*  22:    */     }
/*  23: 58 */     if (state != null) {
/*  24: 58 */       this.state = state;
/*  25:    */     }
/*  26:    */   }
/*  27:    */   
/*  28:    */   synchronized boolean isTerminated()
/*  29:    */   {
/*  30: 72 */     return this.state instanceof TerminatedStateHandler;
/*  31:    */   }
/*  32:    */   
/*  33:    */   synchronized void checkEnlistBeforeUse(CompositeTransaction ct, HeuristicMessage hmsg)
/*  34:    */     throws InvalidSessionHandleStateException, UnexpectedTransactionContextException
/*  35:    */   {
/*  36: 85 */     TransactionContextStateHandler nextState = this.state.checkEnlistBeforeUse(ct, hmsg);
/*  37: 86 */     setState(nextState);
/*  38:    */   }
/*  39:    */   
/*  40:    */   synchronized void sessionClosed()
/*  41:    */   {
/*  42: 96 */     TransactionContextStateHandler nextState = this.state.sessionClosed();
/*  43: 97 */     if (Configuration.isDebugLoggingEnabled()) {
/*  44: 97 */       Configuration.logDebug(this + ": changing state to " + nextState);
/*  45:    */     }
/*  46: 98 */     setState(nextState);
/*  47:    */   }
/*  48:    */   
/*  49:    */   synchronized void transactionSuspended()
/*  50:    */     throws InvalidSessionHandleStateException
/*  51:    */   {
/*  52:109 */     TransactionContextStateHandler nextState = this.state.transactionSuspended();
/*  53:110 */     setState(nextState);
/*  54:    */   }
/*  55:    */   
/*  56:    */   synchronized void transactionResumed()
/*  57:    */     throws InvalidSessionHandleStateException
/*  58:    */   {
/*  59:121 */     TransactionContextStateHandler nextState = this.state.transactionResumed();
/*  60:122 */     setState(nextState);
/*  61:    */   }
/*  62:    */   
/*  63:    */   synchronized void transactionTerminated(CompositeTransaction ct)
/*  64:    */   {
/*  65:132 */     TransactionContextStateHandler nextState = this.state.transactionTerminated(ct);
/*  66:133 */     setState(nextState);
/*  67:    */   }
/*  68:    */   
/*  69:    */   synchronized boolean isSuspendedInTransaction(CompositeTransaction ct)
/*  70:    */   {
/*  71:144 */     return this.state.isSuspendedInTransaction(ct);
/*  72:    */   }
/*  73:    */   
/*  74:    */   public String toString()
/*  75:    */   {
/*  76:149 */     return "a TransactionContext";
/*  77:    */   }
/*  78:    */   
/*  79:    */   boolean isInTransaction(CompositeTransaction tx)
/*  80:    */   {
/*  81:154 */     boolean ret = false;
/*  82:155 */     if (this.state != null) {
/*  83:155 */       ret = this.state.isInTransaction(tx);
/*  84:    */     }
/*  85:156 */     return ret;
/*  86:    */   }
/*  87:    */   
/*  88:    */   boolean isInactiveInTransaction(CompositeTransaction tx)
/*  89:    */   {
/*  90:160 */     boolean ret = false;
/*  91:161 */     if (this.state != null) {
/*  92:161 */       ret = this.state.isInactiveInTransaction(tx);
/*  93:    */     }
/*  94:162 */     return ret;
/*  95:    */   }
/*  96:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions-jta\3.7.0\transactions-jta-3.7.0.jar
 * Qualified Name:     com.atomikos.datasource.xa.session.TransactionContext
 * JD-Core Version:    0.7.0.1
 */